//
//  SettingBaseViewController.m
//  SinaWebo
//
//  Created by wwj on 16/1/18.
//  Copyright © 2016年 亦心. All rights reserved.
//

#import "SettingBaseViewController.h"
#import "SettingGroup.h"
#import "SettingItem.h"
#import "SettingCell.h"


@implementation SettingBaseViewController

-(NSMutableArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

-(void)viewDidLoad{
    [super viewDidLoad];
    
}

- (instancetype)init{
   return [super initWithStyle:UITableViewStyleGrouped];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 5;
}


-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 5;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.dataArray.count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    SettingGroup *group = _dataArray[section];
    return group.items.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    SettingCell *cell = [SettingCell settingCellWithTableView:tableView];
    SettingGroup *group = _dataArray[indexPath.section];
    cell.model = group.items[indexPath.row];
    return cell;
}
@end
